#ifndef T1_MAG_H_
#define T1_MAG_H_

#include "iodef.h"

typedef struct {
        __IO uint32_t RD_REG[3]; /**< The counter number in track A/B/C */
        __IO uint32_t MAG_CTL;   /**< Magnetic Card Reader Control */
        __IO uint32_t INT_STA;   /**< Interrupt Status */
        __IO uint32_t INT_EN;    /**< Interrupt Enable */
        __IO uint32_t INT_CLR;   /**< Interrupt Clear */
        __IO uint32_t CUR_STA;   /**< Current Status */
        __IO uint32_t SAM_PARA;  /**< Sampling Parameters */
        __IO uint32_t MS20_L;    /**< 20ms adjust Low Parameter */
        __IO uint32_t MS20_H;    /**< 20ms adjust High Parameter */
        __IO uint32_t US10_PARA; /**< 10us Parameter */
        __IO uint32_t LPF_CTL;   /**< Low Pass Filter Control */
        __IO uint32_t PGA_CTL;   /**< Programmable Gain Amplifier Control */
        __IO uint32_t PKD_CTL;   /**< Peak Detector Control */
        __IO uint32_t CMP_CTL;   /**< Comparator Control */
        __IO uint32_t PGA_GAIN;  /**< Gain of PGA */
        __IO uint32_t PWD_REF;   /**< Reference and band gap Power */
        __IO uint32_t REF_CTL;   /**< Reference Voltage Control */
        __IO uint32_t ISET_CTL;  /**< Current Control */
        __IO uint32_t RST_PKD;   /**< Reset Control */
}magc_reg_t;

/*
 * MAG_CTL
 */
#define MAG_ADJ_MANUAL          _BIT(1)
#define MAG_EN                  _BIT(0)

/*
 * INT_STA, INT_EN, INT_CLR
 */
#define MAG_INT_DATA_OVER_C     _BIT(10)
#define MAG_INT_DATA_OVER_B     _BIT(9)
#define MAG_INT_DATA_OVER_A     _BIT(8)
#define MAG_INT_DATA_START_C    _BIT(6)
#define MAG_INT_DATA_START_B    _BIT(5)
#define MAG_INT_DATA_START_A    _BIT(4)
#define MAG_INT_PULSE_C         _BIT(2)
#define MAG_INT_PULSE_B         _BIT(1)
#define MAG_INT_PULSE_A         _BIT(0)

#define MAG_INT_BITS            0x777

/*
 * PKD_CTL
 */
#define MAG_PKD_BYP_C           _BIT(6)
#define MAG_PKD_BYP_B           _BIT(5)
#define MAG_PKD_BYP_A           _BIT(4)
#define MAG_PKD_BYP             (MAG_PKD_BYP_C | MAG_PKD_BYP_B | MAG_PKD_BYP_A)
#define MAG_PKD_PWD_C           _BIT(2)
#define MAG_PKD_PWD_B           _BIT(1)
#define MAG_PKD_PWD_A           _BIT(0)
#define MAG_PKD_PWD             (MAG_PKD_PWD_C | MAG_PKD_PWD_B | MAG_PKD_PWD_A)

#define MAGC    ((magc_reg_t *)T1_MAGCARD_BASE)

#endif /* T1_MAG_H_ */
